package com.rizzo.android.domain;

import com.j256.ormlite.field.DatabaseField;
import com.j256.ormlite.table.DatabaseTable;
import com.rizzo.analytics.domain.trend.TrendType;

import java.io.Serializable;
import java.util.Date;

@DatabaseTable(tableName = TrendData.TABLE_NAME)
public class TrendData implements Serializable {

	public static final String TABLE_NAME = "trend_data";
	public static final String ID_FIELD = "_id";
	public static final String TREND_TYPE_FIELD = "trend_type";
	public static final String TIME_STEP_FIELD = "time_step";
	public static final String VALUE_FIELD = "value";
	public static final String TREND_FK_FIELD = "trend_fk";
	public static final String TREND_TYPE_INDEX = "trent_type_idx";
	public static final String[] AVAILABLE_FIELDS = {ID_FIELD, TREND_TYPE_FIELD, TIME_STEP_FIELD, VALUE_FIELD, TREND_FK_FIELD};

	@DatabaseField(id = true, columnName = ID_FIELD, generatedId = true)
	private long id;

	@DatabaseField(canBeNull = false, columnName = TREND_TYPE_FIELD, index = true, indexName = TREND_TYPE_INDEX)
	private TrendType trendType;

	@DatabaseField(canBeNull = false, columnName = TIME_STEP_FIELD)
	private Date timeStep;

	@DatabaseField(canBeNull = false, columnName = VALUE_FIELD)
	private double value;

	@DatabaseField(canBeNull = false, foreign = true, columnName = TREND_FK_FIELD)
	private Trend trend;

	public TrendData(Date timeStep, Trend trend, TrendType trendType, double value) {
		this.timeStep = timeStep;
		this.trend = trend;
		this.trendType = trendType;
		this.value = value;
	}

	public TrendData() {
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public Date getTimeStep() {
		return timeStep;
	}

	public void setTimeStep(Date timeStep) {
		this.timeStep = timeStep;
	}

	public Trend getTrend() {
		return trend;
	}

	public void setTrend(Trend trend) {
		this.trend = trend;
	}

	public TrendType getTrendType() {
		return trendType;
	}

	public void setTrendType(TrendType trendType) {
		this.trendType = trendType;
	}

	public double getValue() {
		return value;
	}

	public void setValue(double value) {
		this.value = value;
	}
}
